﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace supress
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void show(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("hello");
        }

        private void SetDest(object sender, RoutedEventArgs e)
        {
            //根据点击的不同来设定输入的目的地
            Button btn = (Button)sender;
            if ((string)btn.Content == "channel1")
                Console.WriteLine("channel1");
            
        }

        private void DoSend(object sender, RoutedEventArgs e)
        {
            //将数据输入到历史框中
            string text = textBox_input.Text;
            RichtxtboxInput(text, textBox_history);

        }


        public void AddOneRecord(string text)
        {

            textBox_history.AppendText("\r\n");
            textBox_history.AppendText(text);
            textBox_history.AppendText("\r\n");
            textBox_history.ScrollToEnd();
        }

        private void RichtxtboxInput(string txt, RichTextBox richtxtbox)
        {
            Run r = new Run(txt);
            Paragraph para = new Paragraph();
            para.Inlines.Add(r);
            //richtxtbox.Document.Blocks.Clear();
            richtxtbox.Document.Blocks.Add(para);
        }
    }
}
